<?php

include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/shared/common.php';
include_once dirname(dirname(__FILE__)) . '/dal/login_dal.php';
include_once dirname(dirname(dirname(__FILE__))) . '/config/configuration.php';
session_start();

if (!isset($_POST['txtName']) ||
        !isset($_POST['txtPasword']) ||
        $_POST['txtName'] == '' ||
        $_POST['txtPasword'] == '') {
    Redirect('admin/login.php');
} else {
    $user = $_POST['txtName'];
    $pass = $_POST['txtPasword'];
    if (login($user, $pass) == 1) {
        $_SESSION['user'] = $user;
        Redirect('admin/index.php');
    } else {
        echo '<script type="text/javascript">alert("failed"); window.location = "'.ROOT . '/admin/login.php' .'";</script>';
        exit();
//        Redirect('admin/login.php');
    }
}
    

